package service;

import java.util.List;

import base.Service;
import bean.Department;

public class DepartmentS extends Service
{
	public List getList()
	{
		String sql="select * from department";
		return jdbc.queryForList(sql);	
	}
	public void save(Department department)
	{
		String sql="insert into department(dname) values ('"+department.getName()+"')";
		jdbc.execute(sql);
	}
	public boolean delDep(int id)
	{
		String testSql="select count(*) from employee,department where edepartment=dname and did="+id;
		int amount=jdbc.queryForInt(testSql);
		if(amount>0)
		{
            return false;			
		}
		else
		{
			String sql="delete from department where did="+id;
	        jdbc.execute(sql);
	        return true;
		}
	}
}
